Repository navigation
fix(python): read metadata headers past the first three lines - #6174
Closed
saswatdutta1310 wants to merge 1 commit into
Closed
saswatdutta1310 wants to merge 1 commit into
saswatdutta1310 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PythonParser.run_checker()truncatedMETADATA/PKG-INFOto the first three lines before looking forName:andVersion:. Core Metadata is RFC 822 style, soVersion:may legitimately appear later in the header block; those files were silently skipped. The parser now reads the header block up to the first blank line.Closes #6162
Reproduction
With the new test applied to unmodified
HEAD(7bd8e09):Observed (exit 1):
The file has
Name: seleniumon line 2 andVersion: 4.22.0on line 6; the oldlines.splitlines()[:3]cut the version off, so the parser yielded noScanInfo.Root cause
cve_bin_tool/parsers/python.py:331used a fixed three-line window. RFC 822 header fields have no fixed ordering, so a validVersion:field beyond line 3 was discarded before the^Version: (.+)$search.Fix
Split the metadata text at the first blank line (with optional whitespace) and search only inside that header block. This keeps
Version:-like strings in a package description from being matched. One focused regression test was added totest/test_python.py.Scope
One line of parsing logic plus one test. No refactor, no new dependency, no unrelated file changes.
Disclosure
The investigation, reproduction, root-cause analysis and patch were prepared with AI assistance (Hermes). I reviewed the diff and the observed test output. Maintainer review is requested.
Tested
HEAD:python -m pytest test/test_python.py -q -k reads_version_later_in_header— exit 1 (fails as expected).python -m pytest test/test_python.py -qon the patched branch — exit 0, 7 passed.Tests ran in a virtual environment with the repository installed via
pip install -e ..Not-tested
selenium-4.22.0wheel was not downloaded or scanned end-to-end; verification used a METADATA fixture matching the header order from the issue.